<!DOCTYPE html>
<html lang="en">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>${_title}</title>

    <!-- Bootstrap core CSS -->

    <link href="${_css}/bootstrap.min.css" rel="stylesheet">

    <link href="${_font}/css/font-awesome.min.css" rel="stylesheet">
    <link href="${_css}/animate.min.css" rel="stylesheet">

    <!-- Custom styling plus plugins -->
    <link href="${_css}/custom.css" rel="stylesheet">
    <link href="${_css}/icheck/flat/green.css" rel="stylesheet">
    <link href="${_css}/datatables/tools/css/dataTables.tableTools.css" rel="stylesheet">
	<link rel="stylesheet" href="${_css}/base.css">
    <script src="${_js}/jquery.min.js"></script>
    <script src="${_js}/resize.js"></script>
	<script type="text/javascript" src="${_front_js}/jquery.page.js"></script>
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
          <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
          <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
        <![endif]-->
	<style>
		td a{
			cursor:pointer
		}
	</style>
</head>

<body style="background: #F7F7F7;">
<div class="">
    <div class="row">
        <div class="col-md-12 col-sm-12 col-xs-12">
            <div class="x_panel">
	            <div class="x_title">
					<h2>用户资金流水信息</h2>
					<div class="clearfix"></div>
				</div>
                <div class="pull-right">
                	<button id="query" type="button" class="btn btn-info">查询</button>
                	<button type="button" class="btn btn-primary export">导出</button>
                </div>
                <form id="fundRecordForm" class="form-horizontal form-label-left input_mask">
                    <div class="col-md-2 col-sm-2 col-xs-6 form-group has-feedback">
                        <input type="text" class="form-control has-feedback-left" id="username" name="username" value="<#if username?exists>${username}</#if>"
                        placeholder="输入用户名">
                        <span class="fa fa-user form-control-feedback left" aria-hidden="true"></span>
                    </div>
                    <div class="col-md-2 col-sm-2 col-xs-5 form-group has-feedback">
                        <select class="form-control" id="type" name="type">
                        	<option value="" <#if type?exists & type==-1>selected="selected"</#if>>--请选择资金类型--</option>
							<option value="0" <#if type?exists & type==0>selected="selected"</#if>>充值</option>
							<option value="1" <#if type?exists & type==1>selected="selected"</#if>>提现</option>
							<option value="2" <#if type?exists & type==2>selected="selected"</#if>>投资</option>
							<option value="3" <#if type?exists & type==3>selected="selected"</#if>>还款</option>
							<option value="4" <#if type?exists & type==4>selected="selected"</#if>>购买债权</option>
							<option value="5" <#if type?exists & type==5>selected="selected"</#if>>转让债权</option>
							<option value="6" <#if type?exists & type==6>selected="selected"</#if>>资金解冻</option>
							<option value="7" <#if type?exists & type==7>selected="selected"</#if>>资金冻结</option>
							<option value="8" <#if type?exists & type==8>selected="selected"</#if>>借款</option>
							<option value="9" <#if type?exists & type==9>selected="selected"</#if>>注册奖励</option>
							<option value="10" <#if type?exists & type==10>selected="selected"</#if>>邀请奖励</option>
							<option value="11" <#if type?exists & type==11>selected="selected"</#if>>利息管理费</option>
							<option value="12" <#if type?exists & type==12>selected="selected"</#if>>投标冻结</option>
							<option value="13" <#if type?exists & type==13>selected="selected"</#if>>投标成功</option>
						</select>	
                    </div>
                    <form class="form-horizontal">
						<fieldset>
							<div class="control-group">
								<div class="controls">
									<div class="input-prepend input-group">
										<span class="add-on input-group-addon">
											<i class="glyphicon glyphicon-calendar fa fa-calendar"></i>
										</span>
										<input type="text" style="width: 200px" name="createTime" id="reservation" placeholder="请选择创建时间段"
										class="form-control" value="" />
									</div>
								</div>
							</div>
						</fieldset>
					</form>
                 </form>
                <div class="clearfix"></div>
            </div>
            <div class="scroll">
                <div class="x_content">
                    <table id="example" data-action="/admin/fundRecord/list?1=1" class="table table-striped responsive-utilities jambo_table">
                        <thead>
                            <tr class="headings">
                                <th>
	                                <input id="selectAll" type="checkbox" class="tableflat">
	                            </th>
                                <th>序号 </th>
                                <th>资金流水编号</th>
                                <th>用户名</th>
                                <th>用户电话</th>
                                <th>真实姓名</th>
                                <th>资金类型</th>
                                <th>收入(￥)</th>
                                <th>支出 (￥)</th>
                                <th>冻结金额 (￥)</th>
                                <th>可用余额(￥)</th>
                                <th>创建时间</th>
                                <th>备注</th>
                            </tr>
                        </thead>

                        <tbody class="tbody">
			                <#if (pageInfo.pageList?size > 0)>
								<#list pageInfo.pageList as item>
									<tr class="even pointer">
		                                <td class="a-center ">
		                                    <input type="checkbox" class="tableflat" data-id="${item.id}">
		                                </td>
		                                <td>
		                                	${item_index+1}
		                                </td>
		                                <td>
		                                	<#if item.code?exists>
			                                	${item.code}
		                                	</#if>
		                                </td>
		                                <td>
		                                	<#if item.username?exists>
		                                		${item.username}
		                                	</#if>
		                                </td>	
		                               	<td>
		                               		<#if item.phone?exists>
		                                		${item.phone}
		                                	</#if>
		                                </td>     
		                                <td>
		                                	<#if item.realname?exists>
		                                		${item.realname}
		                                	</#if>
		                                </td>                           
		                                <td>
		                                	<#if item.type?exists>
		                                		<#if item.type == 0>
		                                			充值
		                                		<#elseif item.type == 1>
			                                		提现
			                                	<#elseif item.type == 2>
			                                		投资
			                                	<#elseif item.type == 3>
			                                		还款
			                                	<#elseif item.type == 4>
			                                		购买债权
												<#elseif item.type == 5>
			                                		转让债权
			                                	<#elseif item.type == 6>
			                                		资金解冻
												<#elseif item.type == 7>
			                                		资金冻结
			                                	<#elseif item.type == 8>
			                                		借款
												<#elseif item.type == 9>
			                                		注册奖励
			                                	<#elseif item.type == 10>
			                                		邀请奖励
			                                	<#elseif item.type == 11>
			                                		利息管理费
			                                	<#elseif item.type == 12>
			                                		投标冻结
			                                	<#elseif item.type == 13>
			                                		投标成功	                                					                                					                                		
			                                	<#elseif item.type == 14>
			                                		提现解冻	                                					                                					                                		
		                                		</#if>
		                                	</#if>
		                                </td>		
		                                <td>
		                                	<#if item.income?exists>
		                                		<#if (item.income != 0)>
			                                		${item.income?string('0.00')}
			                                	<#else>
			                                	 	0.00
			                                	</#if>
		                                	</#if>
		                                </td>
		                                <td>
		                                	<#if item.expend?exists>
		                                		<#if (item.expend != 0 )>
			                                		${item.expend?string('0.00')}
			                                	<#else>
			                                	 	0.00
			                                	</#if>
		                                	</#if>
		                                </td>
		                                <td>
		                                	<#if item.freezen?exists>
		                                		<#if (item.freezen != 0 )>
			                                		${item.freezen?string('0.00')}
			                                	<#else>
			                                	 	0.00
			                                	</#if>
		                                	</#if>
		                                </td>
		                                <td>
		                                	<#if item.balance?exists>
		                                		<#if (item.balance != 0 )>
			                                		${item.balance?string('0.00')}
			                                	<#else>
			                                	 	0.00
			                                	</#if>
		                                	</#if>
		                                </td>
		                                <td>
		                                	<#if item.createTime?exists>
		                                		${(item.createTime?string("yyyy-MM-dd HH:mm:ss"))!}
		                                	</#if>
		                                </td>
		                                <td>
		                                	<#if item.remark?exists>
		                                		${item.remark} 
		                                	</#if>
		                                </td>
		                             </tr>   
		                        </#list>
	                        <#else>
								<tr class="even pointer">
									<td colspan="11">无记录</td>
								</tr>
							</#if>
                        </tbody>
                    </table>
                    <#if (pageInfo.pageList?size > 0)>
	                	<#include "../base/Page.ftl">
	                </#if>
	                <div id="pageCollect">
	                	<#if (pageInfo.pageList?size > 0)>
							共计：<span style="color:#1ABB9C">${pageInfo.total}</span>笔，
							总收入：<span style="color:#1ABB9C">${pageInfo.sumBlance?string('0.00')}</span>元，
							总支出：<span style="color:#1ABB9C">${pageInfo.sumFee?string('0.00')}</span>元
		                </#if>
	                </div>
                </div>
            </div>
        </div>
        <br />
    </div>
</div>
                    
<script src="${_js}/bootstrap.min.js"></script>

<!-- bootstrap progress js -->
<script src="${_js}/progressbar/bootstrap-progressbar.min.js" type="text/javascript"></script>
<script src="${_js}/nicescroll/jquery.nicescroll.min.js" type="text/javascript"></script>
<!-- icheck -->
<script src="${_js}/icheck/icheck.min.js" type="text/javascript"></script>
<script src="${_js}/custom.js" type="text/javascript"></script>

<!-- PNotify -->
<script src="${_js}/notify/pnotify.core.js" type="text/javascript"></script>
<script src="${_js}/notify/pnotify.buttons.js" type="text/javascript"></script>
<script src="${_js}/notify/pnotify.nonblock.js" type="text/javascript" ></script>

<!-- daterangepicker -->
<script type="text/javascript" src="${_js}/datepicker/moment.min2.js"></script>
<script type="text/javascript" src="${_js}/datepicker/daterangepicker.js"></script>
<script type="text/javascript" src="${_front_js}/date.js"></script>

<script>
    $(document).ready(function(){
        $('input.tableflat').iCheck({
            checkboxClass: 'icheckbox_flat-green',
            radioClass: 'iradio_flat-green'
        });
        
        $('#reservation').daterangepicker(null, function (start, end, label) {
            //console.log(start.toISOString(), end.toISOString(), label);
        });
        
    });
    
    function initData(action) { 
	    var username= $.trim($("#username").val());
    	var type = $.trim($("#type").find("option:selected").val());
    	var reservation = $("#reservation").val();
    	var reg = /^\d{4}[-]\d{2}[-]\d{2}~\d{4}[-]\d{2}[-]\d{2}$/;
    	if(reservation !="" && !reg.test(reservation)){
			new PNotify({
		            	title: '操作提示',
		            	text: '时间格式错误！',
		            	delay: 3e3,
		            	type: 'error'
		        	});
		    return false;
		}
    	if(username !=""){
    		action += "&username="+username;
    	}
    	if(type != ""){
    		action += "&type="+type;
    	}
    	if(reservation !=""){
    		var splitChar = "~";
    		if(reservation.indexOf(splitChar) != -1){
    			var createTimeBegin = $.trim(reservation.split(splitChar)[0]);
    			var createTimeEnd = $.trim(reservation.split(splitChar)[1]);
    			action +="&createTimeBegin="+createTimeBegin;
    			action +="&createTimeEnd="+createTimeEnd;
    		}
    	}
		window.location.href=action;
	} 
	
	$(".btn-info").click(function(){
		initData($("#example").attr('data-action'));
	});
	
	$(".export").click(function(){
		var count=0;
		var ids=new Array();
		$(".tbody .tableflat").each(function(){
			if($(this).parent().hasClass('checked')==true){
				ids[count]=$(this).attr("data-id");
				count++;
			}
		})
		
		/**
		if(count==0){
			alert("请选择导出记录!");
			return false;
		}
		**/
		var action="/admin/export/fund?ids="+ids;
		$("#fundRecordForm").attr("method","post");
		$("#fundRecordForm").attr("action",action);
		$("#fundRecordForm").submit();
	});
	
	var createTimeBegin = "<#if createTimeBegin?exists>${createTimeBegin}</#if>";
	var createTimeEnd = "<#if createTimeEnd?exists>${createTimeEnd}</#if>";
	if(createTimeBegin != "" && createTimeEnd != ""){
		document.getElementById("reservation").value=createTimeBegin+"~"+createTimeEnd
	}
</script>
</body>
</html>